<!DOCTYPE HTML>
<p>Test that script elements that are fetched with CORS enabled and conditionally, pass the expected access controls.</p>
<pre></pre>
<script>
if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}

function log(msg)
{
    document.querySelector("pre").innerHTML = msg;
}

var count = 0;
function finish(ok) {
    // Called by the iframe upon completing the fetch of its script.
    if (ok && count++ < 2) {
        document.querySelector("iframe").contentWindow.location.reload();
        return;
    }
    log((ok ? "PASS" : "FAIL") + ": crossorigin script repeatedly and conditionally loaded.");
    if (window.testRunner)
        testRunner.notifyDone();
}
</script>
<iframe src="resources/iframe-crossorigin-script.html""></iframe>
